/**
 * 统计分析
 * @constructor
 */
function Stat() {

}

Stat.init = function () {
    let vm = new Vue({
        el: "#customModule",
        data: {
            city: '0',
            district: '0',
            town: '0',
            cityList: [],
            districtList: [],
            townList: [],
            quarantineAnimalType: '0',
            productionAnimalType: '猪',
            harmlessAnimalType: '猪',
            animalTypes: ['猪','牛','羊','肉鸡','肉鸭','蛋鸡','蛋鸭','其他'],

            authCity: true,
            authDistrict: true,
            authTown: true
        },
        created() {
            self = this;
        },
        mounted() {
            //this.showCharts();
            this.getAuth();
        },
        computed: {},
        watch: {},
        methods: {
            /**
             * 权限控制
             */
            getAuth() {
                let url = "/UserManage/getAuth";
                axios.post(url).then(data => {
                    if (data.data.code === "200") {
                        // cityCondition: -1,
                        //     districtCondition: -1,
                        //     townCondition: -1,
                        //判断用户权限
                        if (data.data.data.authType == 1) { // 地市权限
                            // city: true,
                            // district: true,
                            // town: true
                            this.city = data.data.data.authCity;
                            this.authDistrict = false;
                            this.authTown = false;
                        }else if (data.data.data.authType == 2){ //区县权限
                            this.city = data.data.data.authCity;
                            this.district = data.data.data.authDistrict;
                            this.authTown = false;
                        }else if (data.data.data.authType == 3){ //乡镇权限
                            this.city = data.data.data.authCity;
                            this.district = data.data.data.authDistrict;
                            this.town = data.data.data.authTown;
                        }
                        this.showCharts();
                    }
                });
            },
            showCharts(){
                this.loadCities();
                this.showBreedEntDisChart();
                this.showSlEntDisChart();
                this.showAnimalChart();
                this.showPigStockChart();
                this.showOtherStockChart();
                this.showQuarantineChart();
                this.showDeadChart();
                this.showSlaughterChart();
                this.showProductionChart();
                this.showHarmlessChart();
                this.showHQuarantineBarChart();
            },
            showBreedEntDisChart() {
                let that = this;
                var myChart = echarts.init(document.getElementById('breedEntDis'));
                var arr = [];
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/entDistribution",    //请求发送到dataActiont处
                    data: {"eType": 1, district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF']
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                arr.push({name:result.data[i].name,value:result.data[i].cnt});
                            }
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                color:colorList,
                                tooltip: {
                                    trigger: 'item'
                                },
                                series: [
                                    {
                                        type: 'pie',
                                        center: ['50%', '50%'],
                                        radius: ['0', '150'],
                                        clockwise: true,
                                        avoidLabelOverlap: true,
                                        hoverOffset: 15,
                                        itemStyle: {
                                            normal: {
                                                color: function(params) {
                                                    return colorList[params.dataIndex]
                                                }
                                            }
                                        },
                                        label: {
                                            show: true,
                                            position: 'outside',
                                            formatter: '{a|{b}：{d}%}\n{hr|}',
                                            rich: {
                                                hr: {
                                                    backgroundColor: 't',
                                                    borderRadius: 3,
                                                    width: 3,
                                                    height: 3,
                                                    padding: [3, 3, 0, -12]
                                                },
                                                a: {
                                                    padding: [-30, 15, -20, 15]
                                                }
                                            }
                                        },
                                        labelLine: {
                                            normal: {
                                                length: 20,
                                                length2: 30,
                                                lineStyle: {
                                                    width: 1
                                                }
                                            }
                                        },
                                        data: arr,
                                    }]
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });//end ajax
            },
            showAnimalChart() {
                let that = this;
                var myChart = echarts.init(document.getElementById('animal'));
                var arr = [];
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/animal",    //请求发送到dataActiont处
                    data: {district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF']
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                arr.push({name:result.data[i].name,value:result.data[i].cnt});
                            }
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                color:colorList,
                                tooltip: {
                                    trigger: 'item'
                                },
                                series: [
                                    {
                                        type: 'pie',
                                        center: ['50%', '50%'],
                                        radius: ['0', '150'],
                                        clockwise: true,
                                        avoidLabelOverlap: true,
                                        hoverOffset: 15,
                                        itemStyle: {
                                            normal: {
                                                color: function(params) {
                                                    return colorList[params.dataIndex]
                                                }
                                            }
                                        },
                                        label: {
                                            show: true,
                                            position: 'outside',
                                            formatter: '{a|{b}：{d}%}\n{hr|}',
                                            rich: {
                                                hr: {
                                                    backgroundColor: 't',
                                                    borderRadius: 3,
                                                    width: 3,
                                                    height: 3,
                                                    padding: [3, 3, 0, -12]
                                                },
                                                a: {
                                                    padding: [-30, 15, -20, 15]
                                                }
                                            }
                                        },
                                        labelLine: {
                                            normal: {
                                                length: 20,
                                                length2: 30,
                                                lineStyle: {
                                                    width: 1
                                                }
                                            }
                                        },
                                        data: arr,
                                    }]
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });//end ajax
            },
            showSlEntDisChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('slEntDis'));
                var arr = [];
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/entDistribution",    //请求发送到dataActiont处
                    data: {"eType": 0, district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF']
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                arr.push({name:result.data[i].name,value:result.data[i].cnt});
                            }
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                color:colorList,
                                tooltip: {
                                    trigger: 'item'
                                },
                                series: [
                                    {
                                        type: 'pie',
                                        center: ['50%', '50%'],
                                        radius: ['0', '150'],
                                        clockwise: true,
                                        avoidLabelOverlap: true,
                                        hoverOffset: 15,
                                        itemStyle: {
                                            normal: {
                                                color: function(params) {
                                                    return colorList[params.dataIndex]
                                                }
                                            }
                                        },
                                        label: {
                                            show: true,
                                            position: 'outside',
                                            formatter: '{a|{b}：{d}%}\n{hr|}',
                                            rich: {
                                                hr: {
                                                    backgroundColor: 't',
                                                    borderRadius: 3,
                                                    width: 3,
                                                    height: 3,
                                                    padding: [3, 3, 0, -12]
                                                },
                                                a: {
                                                    padding: [-30, 15, -20, 15]
                                                }
                                            }
                                        },
                                        labelLine: {
                                            normal: {
                                                length: 20,
                                                length2: 30,
                                                lineStyle: {
                                                    width: 1
                                                }
                                            }
                                        },
                                        data: arr,
                                    }]
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });//end ajax
            },
            showPigStockChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('stockPig'));
                var arr = [];
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/stock",    //请求发送到dataActiont处
                    data: {"type": 1, district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var category = [];
                            var series = [];
                            var animalTypes = ['猪','牛','羊'];
                            var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF']
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                category.push(result.data[i].time);
                            }
                            for(var i=0 ;i<animalTypes.length;i++){
                                var data = [];
                                for (var j = 0; j < result.data.length; j++) {
                                    data.push(result.data[j][animalTypes[i]]);
                                }
                                series.push({
                                    name: animalTypes[i],
                                    type: 'line',
                                    smooth: true,
                                    showAllSymbol: true,
                                    symbol: 'emptyCircle',
                                    symbolSize: 8,
                                    itemStyle: {
                                        normal: {
                                            color:colorList[i]
                                        },
                                    },
                                    data: data
                                })
                            }
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                legend: {
                                    data: animalTypes,
                                    textStyle: {
                                        color: '#B4B4B4'
                                    },
                                    top:'7%',
                                },
                                grid:{
                                    x:'12%',
                                    width:'82%',
                                    y:'12%',
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    data: category,
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4'
                                        }
                                    },
                                    axisTick:{
                                        show:false,
                                    },
                                },
                                yAxis: [{

                                    splitLine: {show: false},
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4',
                                        }
                                    },

                                    axisLabel:{
                                        formatter:'{value} ',
                                    }
                                },
                                    {

                                        splitLine: {show: false},
                                        axisLine: {
                                            lineStyle: {
                                                color: '#B4B4B4',
                                            }
                                        },
                                        axisLabel:{
                                            formatter:'{value} ',
                                        }
                                    }],
                                series: series
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });//end ajax
            },

            showOtherStockChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('stockOther'));
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/stock",    //请求发送到dataActiont处
                    data: {"type": 0, district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var category = [];
                            var series = [];
                            var animalTypes = ['肉鸡','肉鸭','蛋鸡','蛋鸭','其他'];
                            var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF']
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                category.push(result.data[i].time);
                            }
                            for(var i=0 ;i<animalTypes.length;i++){
                                var data = [];
                                for (var j = 0; j < result.data.length; j++) {
                                    data.push(result.data[j][animalTypes[i]]);
                                }
                                series.push({
                                    name: animalTypes[i],
                                    type: 'line',
                                    smooth: true,
                                    showAllSymbol: true,
                                    symbol: 'emptyCircle',
                                    symbolSize: 8,
                                    itemStyle: {
                                        normal: {
                                            color:colorList[i]
                                        },
                                    },
                                    data: data
                                })
                            }
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                legend: {
                                    data: animalTypes,
                                    textStyle: {
                                        color: '#B4B4B4'
                                    },
                                    top:'7%',
                                },
                                grid:{
                                    x:'12%',
                                    width:'82%',
                                    y:'12%',
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    data: category,
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4'
                                        }
                                    },
                                    axisTick:{
                                        show:false,
                                    },
                                },
                                yAxis: [{

                                    splitLine: {show: false},
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4',
                                        }
                                    },

                                    axisLabel:{
                                        formatter:'{value} ',
                                    }
                                },
                                    {

                                        splitLine: {show: false},
                                        axisLine: {
                                            lineStyle: {
                                                color: '#B4B4B4',
                                            }
                                        },
                                        axisLabel:{
                                            formatter:'{value} ',
                                        }
                                    }],
                                series: series
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });//end ajax
            },
            showQuarantineChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('quarantine'));
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/quarantine",    //请求发送到dataActiont处
                    data: {district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var category = [];
                            var data = [];
                            var series = [];
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                category.push(result.data[i].time);
                                data.push(result.data[i].cnt);
                            }
                            series.push({
                                name: '检疫申报次数',
                                type: 'line',
                                smooth: true,
                                showAllSymbol: true,
                                symbol: 'emptyCircle',
                                symbolSize: 8,
                                itemStyle: {
                                    normal: {
                                        color:'#FDD56A'
                                    },
                                },
                                data: data
                            })
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                legend: {
                                    data: ['检疫申报次数'],
                                    textStyle: {
                                        color: '#B4B4B4'
                                    },
                                    top:'7%',
                                },
                                grid:{
                                    x:'12%',
                                    width:'82%',
                                    y:'12%',
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    data: category,
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4'
                                        }
                                    },
                                    axisTick:{
                                        show:false,
                                    },
                                },
                                yAxis: [{

                                    splitLine: {show: false},
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4',
                                        }
                                    },

                                    axisLabel:{
                                        formatter:'{value} ',
                                    }
                                },
                                    {

                                        splitLine: {show: false},
                                        axisLine: {
                                            lineStyle: {
                                                color: '#B4B4B4',
                                            }
                                        },
                                        axisLabel:{
                                            formatter:'{value} ',
                                        }
                                    }],
                                series: series
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });
            },
            showDeadChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('dead'));
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/dead",    //请求发送到dataActiont处
                    data: {district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var category = [];
                            var data = [];
                            var series = [];
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                category.push(result.data[i].time);
                                data.push(result.data[i].cnt);
                            }
                            series.push({
                                name: '死淘数',
                                type: 'line',
                                smooth: true,
                                showAllSymbol: true,
                                symbol: 'emptyCircle',
                                symbolSize: 8,
                                itemStyle: {
                                    normal: {
                                        color:'#FDD56A'
                                    },
                                },
                                data: data
                            })
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                legend: {
                                    data: ['死淘数'],
                                    textStyle: {
                                        color: '#B4B4B4'
                                    },
                                    top:'7%',
                                },
                                grid:{
                                    x:'12%',
                                    width:'82%',
                                    y:'12%',
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    data: category,
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4'
                                        }
                                    },
                                    axisTick:{
                                        show:false,
                                    },
                                },
                                yAxis: [{

                                    splitLine: {show: false},
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4',
                                        }
                                    },

                                    axisLabel:{
                                        formatter:'{value} ',
                                    }
                                },
                                    {

                                        splitLine: {show: false},
                                        axisLine: {
                                            lineStyle: {
                                                color: '#B4B4B4',
                                            }
                                        },
                                        axisLabel:{
                                            formatter:'{value} ',
                                        }
                                    }],
                                series: series
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });
            },

            showSlaughterChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('slaughter'));
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/slaughter",    //请求发送到dataActiont处
                    data: {district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var category = [];
                            var data = [];
                            var series = [];
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                category.push(result.data[i].time);
                                data.push(result.data[i].cnt);
                            }
                            series.push({
                                name: '日屠宰数',
                                type: 'line',
                                smooth: true,
                                showAllSymbol: true,
                                symbol: 'emptyCircle',
                                symbolSize: 8,
                                itemStyle: {
                                    normal: {
                                        color:'#FDD56A'
                                    },
                                },
                                data: data
                            })
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                legend: {
                                    data: ['日屠宰数'],
                                    textStyle: {
                                        color: '#B4B4B4'
                                    },
                                    top:'7%',
                                },
                                grid:{
                                    x:'12%',
                                    width:'82%',
                                    y:'12%',
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    data: category,
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4'
                                        }
                                    },
                                    axisTick:{
                                        show:false,
                                    },
                                },
                                yAxis: [{

                                    splitLine: {show: false},
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4',
                                        }
                                    },

                                    axisLabel:{
                                        formatter:'{value} ',
                                    }
                                },
                                    {

                                        splitLine: {show: false},
                                        axisLine: {
                                            lineStyle: {
                                                color: '#B4B4B4',
                                            }
                                        },
                                        axisLabel:{
                                            formatter:'{value} ',
                                        }
                                    }],
                                series: series
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });
            },
            showProductionChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('production'));
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/production",    //请求发送到dataActiont处
                    data: {"animalType": that.productionAnimalType, district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var category = [];
                            var series = [];
                            var types = ['调入','调出','出生','死淘'];
                            var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF']
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                category.push(result.data[i].time);
                            }
                            for(var i=0 ;i<types.length;i++){
                                var data = [];
                                for (var j = 0; j < result.data.length; j++) {
                                    data.push(result.data[j][types[i]]);
                                }
                                series.push({
                                    name: types[i],
                                    type: 'bar',
                                    smooth: true,
                                    showAllSymbol: true,
                                    symbol: 'emptyCircle',
                                    symbolSize: 8,
                                    itemStyle: {
                                        normal: {
                                            color:colorList[i]
                                        },
                                    },
                                    data: data
                                })
                            }
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                legend: {
                                    data: types,
                                    textStyle: {
                                        color: '#B4B4B4'
                                    },
                                    top:'7%',
                                },
                                grid:{
                                    x:'12%',
                                    width:'82%',
                                    y:'12%',
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    data: category,
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4'
                                        }
                                    },
                                    axisTick:{
                                        show:false,
                                    },
                                },
                                yAxis: [{

                                    splitLine: {show: false},
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4',
                                        }
                                    },

                                    axisLabel:{
                                        formatter:'{value} ',
                                    }
                                },
                                    {

                                        splitLine: {show: false},
                                        axisLine: {
                                            lineStyle: {
                                                color: '#B4B4B4',
                                            }
                                        },
                                        axisLabel:{
                                            formatter:'{value} ',
                                        }
                                    }],
                                series: series
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });//end ajax
            },
            showHarmlessChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('harmless'));
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/harmless",    //请求发送到dataActiont处
                    data: {animalType: that.harmlessAnimalType,district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var category = [];
                            var series = [];
                            var data = [];
                            var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF']
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                category.push(result.data[i].name);
                                data.push(result.data[i].cnt);
                            }
                            series.push({
                                name: '无害化处理动物数量',
                                type: 'bar',
                                smooth: true,
                                showAllSymbol: true,
                                symbol: 'emptyCircle',
                                symbolSize: 8,
                                itemStyle: {
                                    normal: {
                                        color:colorList[i]
                                    },
                                },
                                data: data
                            })
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                legend: {
                                    data: ['无害化处理动物数量'],
                                    textStyle: {
                                        color: '#B4B4B4'
                                    },
                                    top:'7%',
                                },
                                grid:{
                                    x:'12%',
                                    width:'82%',
                                    y:'12%',
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    data: category,
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4'
                                        }
                                    },
                                    axisTick:{
                                        show:false,
                                    },
                                },
                                yAxis: [{

                                    splitLine: {show: false},
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4',
                                        }
                                    },
                                    axisLabel:{
                                        formatter:'{value} ',
                                    }
                                },
                                    {

                                        splitLine: {show: false},
                                        axisLine: {
                                            lineStyle: {
                                                color: '#B4B4B4',
                                            }
                                        },
                                        axisLabel:{
                                            formatter:'{value} ',
                                        }
                                    }],
                                series: series
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });//end ajax
            },
            showHQuarantineBarChart(){
                let that = this;
                var myChart = echarts.init(document.getElementById('quarantineBar'));
                $.ajax({
                    type: "get",
                    async: true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "/stat/quarantineBar",    //请求发送到dataActiont处
                    data: {animalType: that.quarantineAnimalType,district:that.district,town:that.town},
                    dataType: "json",        //返回数据形式为json
                    success: function (result) {
                        //请求成功时执行该函数内容，result即为服务器返回的json对象
                        if (result.code == 200) {
                            var category = [];
                            var series = [];
                            var data = [];
                            var colorList = ['#73DDFF', '#73ACFF', '#FDD56A', '#FDB36A', '#FD866A', '#9E87FF', '#58D5FF']
                            myChart.hideLoading();    //隐藏加载动画
                            for (var i = 0; i < result.data.length; i++) {
                                category.push(result.data[i].name);
                                data.push(result.data[i].cnt);
                            }
                            series.push({
                                name: '检疫申报数量',
                                type: 'bar',
                                smooth: true,
                                showAllSymbol: true,
                                symbol: 'emptyCircle',
                                symbolSize: 8,
                                itemStyle: {
                                    normal: {
                                        color:colorList[i]
                                    },
                                },
                                data: data
                            })
                            myChart.setOption({        //加载数据图表
                                title: {
                                    text: ''
                                },
                                legend: {
                                    data: ['检疫申报数量'],
                                    textStyle: {
                                        color: '#B4B4B4'
                                    },
                                    top:'7%',
                                },
                                grid:{
                                    x:'12%',
                                    width:'82%',
                                    y:'12%',
                                },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    data: category,
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4'
                                        }
                                    },
                                    axisTick:{
                                        show:false,
                                    },
                                },
                                yAxis: [{

                                    splitLine: {show: false},
                                    axisLine: {
                                        lineStyle: {
                                            color: '#B4B4B4',
                                        }
                                    },
                                    axisLabel:{
                                        formatter:'{value} ',
                                    }
                                },
                                    {

                                        splitLine: {show: false},
                                        axisLine: {
                                            lineStyle: {
                                                color: '#B4B4B4',
                                            }
                                        },
                                        axisLabel:{
                                            formatter:'{value} ',
                                        }
                                    }],
                                series: series
                            });
                        } else {
                            window.close();
                        }
                    },
                    error: function (errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                        myChart.hideLoading();
                    }
                });//end ajax
            },
            loadCities() {
                let that = this;
                $.ajax({
                    url: "/city/tableSearch",
                    type: "post",
                    data: JSON.stringify({pageSize: 100}),
                    contentType: "application/json",
                    dataType: "json",
                    success: function (data) {
                        that.cityList = data.data
                        if (data.data[0]) {
                            //that.city = data.data[0].city_id
                            that.loadDistricts(that.city)
                        }
                    }
                })
            },
            loadDistricts(cityId) {
                let that = this;
                $.ajax({
                    url: "/district/tableSearch",
                    type: "post",
                    data: JSON.stringify({city_id: cityId ? cityId : that.city, pageSize: 100}),
                    contentType: "application/json",
                    dataType: "json",
                    success: function (data) {
                        that.districtList = data.data
                        if (data.data[0]) {
                            //that.district = data.data[0].district_id
                            that.loadTowns(that.district)
                        }
                    }
                });
            },
            loadTowns(districtId) {
                let that = this;
                $.ajax({
                    url: "/town/tableSearch",
                    type: "post",
                    data: JSON.stringify({district_id: districtId ? districtId : that.district, pageSize: 100}),
                    contentType: "application/json",
                    dataType: "json",
                    success: function (data) {
                        that.townList = data.data
                    }
                });
            }
        }
    })
};
